package com.ruoyi.hotel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HlCard;
import com.ruoyi.hotel.service.IHlCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 证件类型Controller
 * 
 * @author ruoyi
 * @date 2022-12-10
 */
@RestController
@RequestMapping("/hotel/hlcard")
public class HlCardController extends BaseController
{
    @Autowired
    private IHlCardService hlCardService;

    /**
     * 查询证件类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlCard hlCard)
    {
        startPage();
        List<HlCard> list = hlCardService.selectHlCardList(hlCard);
        return getDataTable(list);
    }

    /**
     * 导出证件类型列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:export')")
    @Log(title = "证件类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlCard hlCard)
    {
        List<HlCard> list = hlCardService.selectHlCardList(hlCard);
        ExcelUtil<HlCard> util = new ExcelUtil<HlCard>(HlCard.class);
        util.exportExcel(response, list, "证件类型数据");
    }

    /**
     * 获取证件类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hlCardService.selectHlCardById(id));
    }

    /**
     * 新增证件类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:add')")
    @Log(title = "证件类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlCard hlCard)
    {
        return toAjax(hlCardService.insertHlCard(hlCard));
    }

    /**
     * 修改证件类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:edit')")
    @Log(title = "证件类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlCard hlCard)
    {
        return toAjax(hlCardService.updateHlCard(hlCard));
    }

    /**
     * 删除证件类型
     */
    @PreAuthorize("@ss.hasPermi('hotel:hlcard:remove')")
    @Log(title = "证件类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hlCardService.deleteHlCardByIds(ids));
    }
}
